HAL OPAMP migration: List of applicable concepts

This section provides information about the HAL OPAMP applicable architecture concepts.

Concepts for OPAMP

Concept

Description

Separation of initialization and configuration functions

The initialization has been split into two levels of functions:

  • HAL_OPAMP_Init: initializes the handle and links it to an OPAMP instance.

  • HAL_OPAMP_SetConfig: configures the common OPAMP settings (the power mode, the speed mode, the OPAMP configuration mode).

Removal and conversion of init structure to configuration structure

The init structure for the OPAMP has been removed from the handle and converted into hal_opamp_config_t structure.

Renaming of the handle structure

The handle structure has been renamed to hal_opamp_handle_t.

Renaming unitary init structures

The structure opamp_InitTypeDef is no longer available and has been replaced by hal_opamp_config_t, hal_opamp_config_input_connection_t, hal_opamp_trimming_offset_pair_t.

Remove MspInit and MspDeInit callbacks

hal_opamp_MspInit and hal_opamp_MspDeInit are no longer available and have been replaced by a user sequence to initializes and configures the OPAMP.

Unitary configuration APIs

New APIs are available to get and set OPAMP features.

Introduction of HAL user data set/get APIs

Two functions to set and get user data are available: HAL_OPAMP_SetUserData and HAL_OPAMP_GetUserData

HAL implementation with LL inline functions

HAL OPAMP APIs now rely on LL APIs rather than performing direct register access.

Define statements and enumerations redirected to LL equivalents

HAL OPAMP define statements and enumerations are based on LL define statements.

Removal of hardware-related macros in HAL2

All hardware macros have been removed from the HAL OPAMP driver, and equivalent services are ensured through the LL APIs.

Revised and optimized HAL state machine

The OPAMP is now managed by a global state machine .

Revised and optimized HAL API status returns

The HAL OPAMP functions were updated to return:

  • HAL_INVALID_PARAM: in case of a NULL p_config structure pointer.

  • HAL_ERROR: in case of an error.

  • HAL_BUSY: in case of an ongoing process.

  • HAL_OK: in case of a successfully completed operation.

Revised and optimized HAL error management

There is no need for error management in the OPAMP driver, as no error conditions are generated by this peripheral.

Replaced TypeDef suffix with _t in type names

All TypeDef parts of the HAL OPAMP driver have been removed and replaced by _t.

Replaced nonmodifiable pointers with const keywords

Const keywords have been added to non-modifiable pointers to ensure that either the pointer itself or the data it points to cannot be modified. This enhances code safety and readability, prevents unintended modifications, and renders code more robust and maintainable.

Assertion implementation and usage in HAL1

The parameters and state are checked using ASSERT_DBG_STATE and ASSERT_DBG_PARAM macros.

Merge HAL extension files with common ones and remove the EX prefix from APIs.

Only one HAL OPAMP header file remains and all macros, define statements, and functions from hal_opamp_ex.h have been moved to hal_opamp.h.

Replace Finite Parameter Defines (Including PPP Instances) with Enum Types at HAL Levels.

Finite parameters (including OPAMP instances) have been converted into enumerated types (enums) at HAL level. This improves code readability, maintainability, and type safety.

Other HAL OPAMP changes

Concept

Consideration

Split each calibration and trimming functions call in two mode

There is no longer a dedicated calibration parameter in the configuration structure. The calibration mode (normal or low power) is now provided as a parameter to the dedicated calibration function.

Trimming for all instances in parallel

  • In HAL1:

    • HAL_OPAMPEx_SelfCalibrate() is used to calibrate a single OPAMP, identified by the handle provided as a parameter.

    • HAL_OPAMPEx_SelfCalibrateAll is used to calibrate multiple OPAMPs, each identified by a handle provided as a parameter.

  • In HAL2:

    • HAL_OPAMP_Calibrate() is used to calibrate a single OPAMP, identified by the handle provided as a parameter.

    • HAL_OPAMP_CalibrateParallel() is used to calibrate multiple OPAMPs simultaneously. However, the corresponding handles of these OPAMPs must be linked using the function HAL_OPAMP_SetLinkNextHandle().